package com.reger.rongcloud.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;

import com.reger.rongcloud.properties.RongCloudProperties;

import io.rong.RongCloud;

@Configuration
@EnableConfigurationProperties(RongCloudProperties.class)
public class RongCloudAutoConfiguration {
	@Autowired
	private RongCloudProperties rongCloudProperties;

	@Bean
	public RongCloud rongCloud() {
		Assert.hasText(rongCloudProperties.getAppKey(), "融云AppKey不可以为空");
		Assert.hasText(rongCloudProperties.getAppSecret(), "融云AppSecret不可以为空");
		return RongCloud.getInstance(rongCloudProperties.getAppKey(), rongCloudProperties.getAppSecret());
	}
}
